#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 333333;
ll a[maxn];
vector<ll> X;

int getidx( ll x ){
	return lower_bound(X.begin(), X.end(), x ) - X.begin() + 1;
}

struct node{
	ll a,b;
}add[maxn], que[maxn];

void solve(){
	int n,q; cin >> n >> q;
	for ( int i=1; i<=n; i++ ){
		ll x,w; cin >> x >> w;
		X.push_back(x);
		add[i] = {x, w};
	}
	for ( int i=1; i<=q; i++ ){
		ll l,r; cin >> l >> r;
		X.push_back(l); X.push_back(r);
		que[i] = {l, r};
	}
	
	sort(X.begin(), X.end());
	X.erase(unique(X.begin(),X.end()), X.end());
	
	for ( int i=1; i<=n; i++ ){
		int x = getidx(add[i].a);
		int k = add[i].b;
		a[x] += k;
	}
	for ( int i=1; i<=n; i++ ) a[i] += a[i-1];
	for ( int i=1; i<=q; i++ ){
		int l = getidx(que[i].a);
		int r = getidx(que[i].b);
		cout << a[r] - a[l-1] << '\n';
	}
}

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	int _=1; while(_--) solve();
	return 0;
}
